<?php
if($idChungLoai==null)
{?>
	<div id="content">
		
		<h2>Không có sản phẩm nào trong danh mục chủng loại</h2>
        <div class="box">
       
			<table>
            	<tr class="highlight">
					<td colspan="5" align="left" class="action">
						<ul>
							<li><a class="edit" href="sua_chungloai.php?id=<?php echo $idChungLoai?>" title="edit"></a></li>
							<li><a class="add" href="them_chungloai.php" title="add"></a></li>
							<li><a class="delete" href="xoa_chungloai.php?id=<?php echo $idChungLoai?>" title="delete"></a></li>
							<li><a class="mark" href="#" title="mark"></a></li>
						</ul>
					</td>
				</tr>
            </table>
        </div>
    </div>
<?php 
}
else
{
$chungloai=getChungLoai($idChungLoai);
//var_dump($chungloai);exit();
$listSanPham=listSanPham($idChungLoai);//id chủng loại lấy từ phương thức get show_sanpham.php
?>
<div id="content">
		
		<h2>Danh sách sản phẩm trong <?php echo $chungloai[2];?></h2>
		<div class="box">
       
			<table>
            	<tr class="highlight">
					<td colspan="5" align="left" class="action">
						<ul>
							<li><a class="edit" href="sua_chungloai.php?id=<?php echo $idChungLoai?>" title="edit"></a></li>
							<li><a class="add" href="them_chungloai.php" title="add"></a></li>
							<li><a class="delete" href="xoa_chungloai.php?id=<?php echo $idChungLoai?>" title="delete"></a></li>
							<li><a class="mark" href="#" title="mark"></a></li>
						</ul>
					</td>
				</tr>
				<tr>
					<th class="col1">Tên sản phẩm</th>
					
					<th class="col3">Giá</th>
					<th class="col4">Số lần xem</th>
					<th class="col5">Số lượng tồn kho</th>
                    <th class="col5">Số lần mua</th>
                    <th class="col2">Ngày cập nhật</th>
                    <th class="col5">Thao tác</th>

				</tr>
            <?php
			for($i=0;$i<count($listSanPham);$i++)
			{?>
				
				<tr <?php if($i%2==0) {echo 'class="highlight"';}?>>
					<td><a href="#" title="<?php echo $listSanPham[$i]["TenSP"];?>"><?php echo $listSanPham[$i]["TenSP"];?></a></td>
					<td><?php echo $listSanPham[$i]["Gia"];?></td>
					<td><?php echo $listSanPham[$i]["SoLanXem"];?></td>
                    <td><?php echo $listSanPham[$i]["SoLuongTonKho"];?></td>
                    <td><?php echo $listSanPham[$i]["SoLanMua"];?></td>
                    
                    <td><?php
					$date=date('d/m/Y',$listSanPham[$i]["NgayCapNhat"]);
                    echo $date?></td>
                    
					<td class="action">
						<ul>
							<li><a class="edit" href="sua_sanpham.php?id=<?php echo $listSanPham[$i]['idSP'];?>" title="edit"></a></li>
							<li><a class="add" href="them_sanpham.php?idCL=<?php echo $chungloai[1];;?>" title="add"></a></li>
							<li><a class="delete" href="xoa_sanpham.php?<?php echo 'idSP='.$listSanPham[$i]['idSP'].'&&idCL='.$chungloai[1] ;?>" title="delete"></a></li>
							<li><a class="mark" href="#" title="mark"></a></li>
						</ul>
					</td>
				</tr>
                <?php }?>
			</table>
			<p id="pagin">
				&laquo; <a href="#" title="">previous</a> &ndash;
				<a href="#" title="">1</a>
				<a href="#" title="">2</a>
				<a href="#" title="">3</a>
				<a href="#" title="">4</a>
				<a href="#" title="">5</a>
				<a href="#" title="">6</a>
				<a href="#" title="">7</a>
				<a href="#" title="">8</a>
				<a href="#" title="">9</a>
				&ndash; <a href="#" title="">next</a> &raquo;
			</p>
		</div>
	</div>
    <?php }?>